{include file="public/_head" /}
<div class="container">
    <div class="row">
        <div class="col-sm-12 col-md-8">
            <h1 class="article-title">{$articleInfo.title}</h1>
            <div class="status">{$articleInfo.click}阅读-{$articleInfo.commemt|default=0}评论-作者：{$articleInfo.author}
                {volist name="articleInfo.tags" id="vo"}
                <span class="label label-default">{$vo}</span>
                {/volist}
            </div>
            <div class="article-content">
                <blockquote>
                    {$articleInfo.desc|raw}
                </blockquote>
                {$articleInfo.content|raw}
            </div>
            <div class="article-comment">
                <div class="page-header"><b>相关评论</b></div>
                <div class="comment-content">
                    <form action="#">
                        <input type="hidden" name="articleid" value="{$articleInfo.id}">
                        <input type="hidden" name="userid" value="{:session('index.id')}">
                        <div class="form-group">
                            <textarea class="form-control" id="content" name="content" rows="5" cols=""></textarea>
                        </div>
                        <div class="form-group pull-right">
                            <button class="btn btn-primary" id="commentSub">评论（请认真评论）</button>
                        </div>
                    </form>
                </div>
                <div class="clearfix"></div>
                <div class="comment-list">
                    <div class="comment-list-item">
                        <div class="info">赏金<small>2018-11-11 23:28:22</small></div>
                        <div class="content">这篇文章真的不错！</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-12 col-md-4">
            <div class="affix">
                <div class="page-header h3">推荐文章</div>
                <div class="topic-list">
                    {volist name="upArticles" id="vo"}
                    <div class="topic-list-item">
                        <a href="{:url('index/article/info', ['id' => $vo.id])}" class="title">{$vo.title}</a>
                    </div>
                    {/volist}
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/_footer" /}
<script src="/static/lib/layer/layer.js"></script>
<script>
    $(function () {
        $('#commentSub').click(function () {
            var id = "{:session('index.id')}";
            if (!id) {
                layer.open({
                    title:'评论失败',
                    content:'请登录后再来评论！',
                    icon:5,
                    anim:6
                });
            }else {
                $.ajax({
                    url:"{:url('index/article/comment')}",
                    type:'post',
                    data:$('form').serialize(),
                    dataType:'json',
                    success:function (data) {
                        console.log(data);
                        if (data.code == 1) {
                            layer.msg(data.msg, {
                                icon:6,
                                time:2000
                            }, function () {
                                location.href = location.href;
                            });
                        }else {
                            layer.open({
                                title:'评论失败',
                                content:data.msg,
                                icon:5,
                                anim:6
                            });
                        }
                    }
                });
            }
            return false;
        });
    });
</script>
</body>
</html>